package cn.anecansaitin.whimsy.test.explayer.layer;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.core.registries.Registries;
import org.jetbrains.annotations.Nullable;
import software.bernie.geckolib.core.animatable.GeoAnimatable;
import software.bernie.geckolib.core.object.Color;
import software.bernie.geckolib.renderer.GeoObjectRenderer;

public class PlayerLayerRender<T extends GeoAnimatable> extends GeoObjectRenderer<T> {
    private final GeoAnimatable animatable;

    public PlayerLayerRender(PlayerLayerModel<T> model, T animatable) {
        super(model);
        this.animatable = animatable;
    }

    public T getAnimatable() {
        return (T) animatable;
    }

    @Override
    public void render(PoseStack poseStack, T animatable, @Nullable MultiBufferSource bufferSource, @Nullable RenderType renderType, @Nullable VertexConsumer buffer, int packedLight) {
            //让layer的渲染类型与主体保持一致
//            super.render(poseStack, animatable, bufferSource, RenderType.itemEntityTranslucentCull(getTextureLocation(animatable)), null, packedLight);
            super.render(poseStack, animatable, bufferSource, null, null, packedLight);
    }
//todo 这是临时测试手段，要改为通过玩家技能状态来获取
    private Color color = new Color(0x7fffffff);

    @Override
    public Color getRenderColor(T animatable, float partialTick, int packedLight) {
        return color;
    }
}
